<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/feedback.css" />
		<link rel="stylesheet" type="text/css" href="css/iconfont3.css">
		<link rel="stylesheet" type="text/css" href="css/iconfont4.css">
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
		<link href="css/mui.poppicker.css" rel="stylesheet" />
		<script type="text/javascript" src="jquery.js"></script> 
		<script type="text/javascript" src="jquery.qrcode.min.js"></script> 
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
		<style>
			/* 主界面css*/
			html,
			body {
				background-color: #efeff4;
			}
			.mui-views,
			.mui-view,
			.mui-pages,
			.mui-page,
			.mui-page-content {
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 0;
				width: 100%;
				height: 100%;
				background-color: #efeff4;
			}
			.mui-pages {
				top: 46px;
				height: auto;
			}
			.mui-scroll-wrapper,
			.mui-scroll {
				background-color: #efeff4;
			}
			.mui-page.mui-transitioning {
				-webkit-transition: -webkit-transform 300ms ease;
				transition: transform 300ms ease;
			}
			.mui-page-left {
				-webkit-transform: translate3d(0, 0, 0);
				transform: translate3d(0, 0, 0);
			}
			.mui-ios .mui-page-left {
				-webkit-transform: translate3d(-20%, 0, 0);
				transform: translate3d(-20%, 0, 0);
			}
			.mui-navbar {
				position: fixed;
				right: 0;
				left: 0;
				z-index: 10;
				height: 44px;
				background-color: #f7f7f8;
			}
			.mui-navbar .mui-bar {
				position: absolute;
				background: transparent;
				text-align: center;
			}
			.mui-android .mui-navbar-inner.mui-navbar-left {
				opacity: 0;
			}
			.mui-ios .mui-navbar-left .mui-left,
			.mui-ios .mui-navbar-left .mui-center,
			.mui-ios .mui-navbar-left .mui-right {
				opacity: 0;
			}
			.mui-navbar .mui-btn-nav {
				-webkit-transition: none;
				transition: none;
				-webkit-transition-duration: .0s;
				transition-duration: .0s;
			}
			.mui-navbar .mui-bar .mui-title {
				display: inline-block;
				width: auto;
			}
			.mui-page-shadow {
				position: absolute;
				right: 100%;
				top: 0;
				width: 16px;
				height: 100%;
				z-index: -1;
				content: '';
			}
			.mui-page-shadow {
				background: -webkit-linear-gradient(left, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, .01) 50%, rgba(0, 0, 0, .2) 100%);
				background: linear-gradient(to right, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, .01) 50%, rgba(0, 0, 0, .2) 100%);
			}
			.mui-navbar-inner.mui-transitioning,
			.mui-navbar-inner .mui-transitioning {
				-webkit-transition: opacity 300ms ease, -webkit-transform 300ms ease;
				transition: opacity 300ms ease, transform 300ms ease;
			}
			.mui-page {
				display: none;
			}
			.mui-pages .mui-page {
				display: block;
			}
			.mui-page .mui-table-view:first-child {
				margin-top: 15px;
			}
			.mui-page .mui-table-view:last-child {
				margin-bottom: 30px;
			}
			.mui-table-view {
				margin-top: 20px;
			}
			
			.mui-table-view span.mui-pull-right {
				color: #999;
			}
			.mui-table-view-divider {
				background-color: #efeff4;
				font-size: 14px;
			}
			.mui-table-view-divider:before,
			.mui-table-view-divider:after {
				height: 0;
			}
			.head {
				height: 40px;
			}
			#head {
				line-height: 40px;
			}
			.head-img {
				width: 40px;
				height: 40px;
			}
			#head-img1 {
				position: absolute;
				bottom: 10px;
				right: 40px;
				width: 40px;
				height: 40px;
			}
			.update {
				font-style: normal;
				color: #999999;
				margin-right: -25px;
				font-size: 15px
			}
			.mui-fullscreen {
				position: fixed;
				z-index: 20;
				background-color: #000;
			}
			.mui-ios .mui-navbar .mui-bar .mui-title {
				position: static;
			}
			/*问题反馈在setting页面单独的css*/
			#feedback .mui-popover{
				position: fixed;
			}
			#feedback .mui-table-view:last-child {
			    margin-bottom: 0px;
			}
			#feedback .mui-table-view:first-child {
			    margin-top: 0px;
			}
			
			/*企业好友css*/
			
			 .oa-contact-cell.mui-table .mui-table-cell {
				padding: 11px 0;
				vertical-align: middle;
			}
			
			.oa-contact-cell {
				position: relative;
				margin: -11px 0;
			}
	
			.oa-contact-avatar {
				width: 75px;
			}
			.oa-contact-avatar img {
				border-radius: 50%;
			}
			.oa-contact-content {
				width: 100%;
			}
			.oa-contact-name {
				margin-right: 20px;
			}
			.oa-contact-name, oa-contact-position {
				float: left;
			}
			/*选择时间和地址的位置*/
				.ui-alert {
			
				padding: 9px 30px;
				font-size: 16px;
			}
			
		</style>
		<link rel="stylesheet" type="text/css" href="css/feedback.css" />
		<link rel="stylesheet" type="text/css" href="css/iconfont.css">
		<link rel="stylesheet" type="text/css" href="css/iconfont2.css">
	</head>
	<body class="mui-fullscreen" onload="checkJob();findComId()">
		<script>
			var id=localStorage.getItem("employeeid");
			var eJob="";
			var comId="";
			function checkJob(){
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
						console.log('网络正常,正在发送请求...');
							 mui.ajax({
                                    url:"http://113.71.26.27:8080/tpl/phone/findEmp",
                                    async:true,
     								type:'post',
     								dataType:"json", 
     								data:{
     									id:id
     								},
     							 	success:function(data){
     							 		eJob=data.job;
     							 		
     								}
     						});
					} else {
						mui.toast("当前网络不给力，请稍后再试...");
				}

			}
			
			
			function findComId(){
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
						console.log('网络正常,正在发送请求...');
							 mui.ajax({
                                    url:"http://113.71.26.27:8080/tpl/phone/getAllCompany",
                                    async:true,
     								type:'post',
     								data:{
     									id:id
     								},
     							 	success:function(data){
     							 		for(var i=0;i<data.length;i++){
     							 			comId=data[i].id;
     							 		}
     							 		
     								}
     						});
					} else {
						mui.toast("当前网络不给力，请稍后再试...");
				}

			}
			
			
			function newDepart(){
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
					console.log('网络正常,正在发送请求...');
					if(eJob!="普通员工"){
					  if($("#nDname").val()!="" && $("#nDdescriber").val()!="" && $("#nDmanager").val()!=""){
						mui.ajax({
                 				async:true,
     							type:'post',
                				url:'http://113.71.26.27:8080/tpl/phone/addDepart',
                				data:{
                					name:$("#nDname").val(),
                					describer:$("#nDdescriber").val(),
                					manager:$("#nDmanager").val(),
                					companyid:comId,
                				},// 你的formid
                			    success: function(data){
                			    	if(data=="ok" || data.equals("ok")){
                			    		window.location.href= "bumen-list.html";
                			    		mui.toast("创建成功！");
                			    	}else{
                			    		mui.toast("创建失败，请重新创建！");
                			    	}
                			    }
                			 });
                	  }else{
                	  	mui.toast("请输入完整信息！");
                	  }
                 	}
					else{
						mui.toast("权限不足！");
					}
				}else {
						mui.toast("当前网络不给力，请稍后再试...");
					}
			}
		</script>
			<div class="mui-navbar-inner mui-bar mui-bar-nav">
				<button type="button" class="mui-left mui-btn  mui-btn-link mui-btn-nav mui-pull-left" onclick="javascript:window.location.href='bumen-list.html' ">
					<span class="mui-icon mui-icon-left-nav"></span>
				</button>
				<h1 class="mui-title">新建部门 </h1>
				<button onclick="newDepart()" class="mui-right  mui-btn  mui-btn-link mui-btn-nav mui-pull-right">
					<a  class="mui-btn-primary">提交</a>
				</button>
			</div>
			<div class="mui-page-content" style="margin-top: 40px;">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll">
						<div class="mui-content-padded" style="margin: 0px; line-height: ; ">
						<form id="newDepart" class="mui-input-group">									
							<div class="mui-input-row">
								<label>部门名称</label>
								<input id="nDname" type="text" class="mui-input-clear" name="name" placeholder="">
							</div>
							<div class="mui-input-row">
								<label>部门负责人</label>
								<input id="nDmanager" type="text" class="mui-input-clear" name="manager" placeholder="">
							</div>			
							<div class="mui-input-row"style="height: 100px">
								<label>部门描述</label>
								<textarea id="nDdescriber" rows="5" name="describer"/></textarea>
							</div>
						</form>
						</div>
					</div>	
				</div>
			</div>
	</body>
	<script src="js/mui.min.js "></script>
	<script src="js/mui.view.js "></script>
	<script src='js/feedback.js'></script>
	<script src="js/mui.picker.min.js"></script>
	<script src="js/mui.poppicker.js"></script>
	<script src="js/city.data.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		/**
		 * 重写返回事件
		 */
		mui.back = function(){
			
			window.location.href = "bumen-list.html";
		}
	</script>
</html>

